package 题目集.线段树or树状数组.线段树;

import java.io.*;

/**
 *给定一个长度为n的数组arr，实现如下两种操作
 * 操作 1 l r k d : arr[l..r]范围上的数依次加上等差数列，首项k，公差d
 * 操作 2 p       : 查询arr[p]的值
 * 测试链接 : https://www.luogu.com.cn/problem/P1438
 * 思路：
 *      给一个区间加上一个等差数列，相当于对这个数列的差分数列进行下面的操作：
 *          1.给l位置加上一个首项
 *          2.给 l+1到r位置加上公差
 *          3.给r+1位置减去一个末项
 *      单点查询就是对差分数组的求和。
 *      相当于需要区间增加和区间求和.线段树
 */
public class ch09_无聊的数列 {
    static int n, m, tn;
    static Node[] tree;
    static int[] src;
    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        Reader sc = new Reader();
        n = sc.nextInt();
        m = sc.nextInt();
        tn = (int) Math.pow(2, 1 + Math.ceil(Math.log(n) / Math.log(2)));
        tree = new Node[tn];
        src = new int[n + 1];
        int pre = 0;
        for (int i = 1; i < src.length; i++) {
            int cur = sc.nextInt();
            src[i] = cur - pre;
            pre = cur;
        }
        build(1, 1, n);
        for (int i = 0; i < m; i++) {
            int op = sc.nextInt();
            if (op == 1) {
                int l = sc.nextInt();
                int r = sc.nextInt();
                int a1 = sc.nextInt();
                int d = sc.nextInt();
                add(1, l, l, a1);
                if (l < r) {
                    add(1, l + 1, r, d);
                }
                if (r < n) {    //r==n时没必要执行
                    int an = (r - l) * d + a1;
                    add(1, r + 1, r + 1, -an);
                }
            } else {
                int index = sc.nextInt();
                long res = query(1, 1, index);
                pw.println(res);
            }
        }
        pw.flush();
    }

    public static void build(int i, int l, int r) {
        tree[i] = new Node(l, r);
        if (l == r) {
            tree[i].sum = src[l];
            return;
        }
        int m = l + r >> 1;
        build(i << 1, l, m);
        build(i << 1 | 1, m + 1, r);
        pull(i);
    }

    public static void add(int i, int l, int r, int v) {
        if (lazy(i, l, r)) {
            addLazy(i, v);
        } else {
            push(i);
            int m = tm(i);
            if (l <= m) {
                add(i << 1, l, r, v);
            }
            if (m < r) {
                add(i << 1 | 1, l, r, v);
            }
            pull(i);
        }
    }

    public static long query(int i, int l, int r) {
        if (lazy(i, l, r)) {
            return tree[i].sum;
        }
        push(i);
        long res = 0;
        int m = tm(i);
        if (l <= m) {
            res += query(i << 1, l, r);
        }
        if (m < r) {
            res += query(i << 1 | 1, l, r);
        }
        return res;
    }

    public static int tm(int i) {
        return tree[i].l + tree[i].r >> 1;
    }

    public static void pull(int i) {
        tree[i].sum = tree[i << 1].sum + tree[i << 1 | 1].sum;
    }

    public static void push(int i) {
        if (tree[i].lazy != 0) {
            addLazy(i << 1, tree[i].lazy);
            addLazy(i << 1 | 1, tree[i].lazy);
            tree[i].lazy = 0;
        }
    }

    public static void addLazy(int i, long v) {
        tree[i].sum += tree[i].len * v;
        tree[i].lazy += v;
    }

    public static boolean lazy(int i, int l, int r) {
        return l <= tree[i].l && tree[i].r <= r;
    }

    static class Node {
        int l, r, len;
        long sum, lazy;

        @Override
        public String toString() {
            return "Node{" +
                    "l=" + l +
                    ", r=" + r +
                    ", len=" + len +
                    ", sum=" + sum +
                    ", lazy=" + lazy +
                    '}';
        }

        public Node(int l, int r) {
            this.l = l;
            this.r = r;
            len = r - l + 1;
        }
    }

    static class Reader {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (Exception ignored) {
            }
            return (int) in.nval;
        }
    }
}
